package org.xtext.telcodev.dsl.serializer;

import com.google.inject.Inject;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.GroupAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.TokenAlias;
import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynNavigable;
import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition;
import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer;
import org.xtext.telcodev.dsl.services.VoiSGrammarAccess;

@SuppressWarnings("restriction")
public class AbstractVoiSSyntacticSequencer extends AbstractSyntacticSequencer {

	protected VoiSGrammarAccess grammarAccess;
	protected AbstractElementAlias match_ConcatenationTerminal_LeftParenthesisKeyword_0_0_a;
	protected AbstractElementAlias match_ConcatenationTerminal_LeftParenthesisKeyword_0_0_p;
	protected AbstractElementAlias match_MathTerminal_LeftParenthesisKeyword_0_0_a;
	protected AbstractElementAlias match_MathTerminal_LeftParenthesisKeyword_0_0_p;
	protected AbstractElementAlias match_State___LeftCurlyBracketKeyword_1_1_RightCurlyBracketKeyword_1_3__a;
	protected AbstractElementAlias match_State___LeftCurlyBracketKeyword_1_1_RightCurlyBracketKeyword_1_3__p;
	protected AbstractElementAlias match_State___RightCurlyBracketKeyword_1_3_LeftCurlyBracketKeyword_1_1__a;
	protected AbstractElementAlias match_TerminalBoolExpression_LeftParenthesisKeyword_0_0_a;
	protected AbstractElementAlias match_TerminalBoolExpression_LeftParenthesisKeyword_0_0_p;
	
	@Inject
	protected void init(IGrammarAccess access) {
		grammarAccess = (VoiSGrammarAccess) access;
		match_ConcatenationTerminal_LeftParenthesisKeyword_0_0_a = new TokenAlias(true, true, grammarAccess.getConcatenationTerminalAccess().getLeftParenthesisKeyword_0_0());
		match_ConcatenationTerminal_LeftParenthesisKeyword_0_0_p = new TokenAlias(true, false, grammarAccess.getConcatenationTerminalAccess().getLeftParenthesisKeyword_0_0());
		match_MathTerminal_LeftParenthesisKeyword_0_0_a = new TokenAlias(true, true, grammarAccess.getMathTerminalAccess().getLeftParenthesisKeyword_0_0());
		match_MathTerminal_LeftParenthesisKeyword_0_0_p = new TokenAlias(true, false, grammarAccess.getMathTerminalAccess().getLeftParenthesisKeyword_0_0());
		match_State___LeftCurlyBracketKeyword_1_1_RightCurlyBracketKeyword_1_3__a = new GroupAlias(true, true, new TokenAlias(false, false, grammarAccess.getStateAccess().getLeftCurlyBracketKeyword_1_1()), new TokenAlias(false, false, grammarAccess.getStateAccess().getRightCurlyBracketKeyword_1_3()));
		match_State___LeftCurlyBracketKeyword_1_1_RightCurlyBracketKeyword_1_3__p = new GroupAlias(true, false, new TokenAlias(false, false, grammarAccess.getStateAccess().getLeftCurlyBracketKeyword_1_1()), new TokenAlias(false, false, grammarAccess.getStateAccess().getRightCurlyBracketKeyword_1_3()));
		match_State___RightCurlyBracketKeyword_1_3_LeftCurlyBracketKeyword_1_1__a = new GroupAlias(true, true, new TokenAlias(false, false, grammarAccess.getStateAccess().getRightCurlyBracketKeyword_1_3()), new TokenAlias(false, false, grammarAccess.getStateAccess().getLeftCurlyBracketKeyword_1_1()));
		match_TerminalBoolExpression_LeftParenthesisKeyword_0_0_a = new TokenAlias(true, true, grammarAccess.getTerminalBoolExpressionAccess().getLeftParenthesisKeyword_0_0());
		match_TerminalBoolExpression_LeftParenthesisKeyword_0_0_p = new TokenAlias(true, false, grammarAccess.getTerminalBoolExpressionAccess().getLeftParenthesisKeyword_0_0());
	}
	
	@Override
	protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if(ruleCall.getRule() == grammarAccess.getML_COMMENTRule())
			return getML_COMMENTToken(semanticObject, ruleCall, node);
		return "";
	}
	
	protected String getML_COMMENTToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if (node != null)
			return getTokenText(node);
		return "/*";
	}
	
	@Override
	protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) {
		if (transition.getAmbiguousSyntaxes().isEmpty()) return;
		List<INode> transitionNodes = collectNodes(fromNode, toNode);
		for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) {
			List<INode> syntaxNodes = getNodesFor(transitionNodes, syntax);
			if(match_ConcatenationTerminal_LeftParenthesisKeyword_0_0_a.equals(syntax))
				emit_ConcatenationTerminal_LeftParenthesisKeyword_0_0_a(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_ConcatenationTerminal_LeftParenthesisKeyword_0_0_p.equals(syntax))
				emit_ConcatenationTerminal_LeftParenthesisKeyword_0_0_p(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_MathTerminal_LeftParenthesisKeyword_0_0_a.equals(syntax))
				emit_MathTerminal_LeftParenthesisKeyword_0_0_a(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_MathTerminal_LeftParenthesisKeyword_0_0_p.equals(syntax))
				emit_MathTerminal_LeftParenthesisKeyword_0_0_p(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_State___LeftCurlyBracketKeyword_1_1_RightCurlyBracketKeyword_1_3__a.equals(syntax))
				emit_State___LeftCurlyBracketKeyword_1_1_RightCurlyBracketKeyword_1_3__a(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_State___LeftCurlyBracketKeyword_1_1_RightCurlyBracketKeyword_1_3__p.equals(syntax))
				emit_State___LeftCurlyBracketKeyword_1_1_RightCurlyBracketKeyword_1_3__p(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_State___RightCurlyBracketKeyword_1_3_LeftCurlyBracketKeyword_1_1__a.equals(syntax))
				emit_State___RightCurlyBracketKeyword_1_3_LeftCurlyBracketKeyword_1_1__a(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_TerminalBoolExpression_LeftParenthesisKeyword_0_0_a.equals(syntax))
				emit_TerminalBoolExpression_LeftParenthesisKeyword_0_0_a(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_TerminalBoolExpression_LeftParenthesisKeyword_0_0_p.equals(syntax))
				emit_TerminalBoolExpression_LeftParenthesisKeyword_0_0_p(semanticObject, getLastNavigableState(), syntaxNodes);
			else acceptNodes(getLastNavigableState(), syntaxNodes);
		}
	}

	/**
	 * Syntax:
	 *     '('*
	 */
	protected void emit_ConcatenationTerminal_LeftParenthesisKeyword_0_0_a(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     '('+
	 */
	protected void emit_ConcatenationTerminal_LeftParenthesisKeyword_0_0_p(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     '('*
	 */
	protected void emit_MathTerminal_LeftParenthesisKeyword_0_0_a(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     '('+
	 */
	protected void emit_MathTerminal_LeftParenthesisKeyword_0_0_p(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ('{' '}')*
	 */
	protected void emit_State___LeftCurlyBracketKeyword_1_1_RightCurlyBracketKeyword_1_3__a(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ('{' '}')+
	 */
	protected void emit_State___LeftCurlyBracketKeyword_1_1_RightCurlyBracketKeyword_1_3__p(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ('}' '{')*
	 */
	protected void emit_State___RightCurlyBracketKeyword_1_3_LeftCurlyBracketKeyword_1_1__a(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     '('*
	 */
	protected void emit_TerminalBoolExpression_LeftParenthesisKeyword_0_0_a(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     '('+
	 */
	protected void emit_TerminalBoolExpression_LeftParenthesisKeyword_0_0_p(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
}
